#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>

int main()
{
    Json::Value root;
    root["x"] = 100;
    root["y"] = 200;
    root["hello world"] = 300;
    root["123"] = "hello world";

    Json::StyledWriter writer1;
    std::string s1 = writer1.write(root);
    std::cout << s1 << std::endl;

    Json::FastWriter writer2;
    std::string s2 = writer2.write(root);
    std::cout << s2 << std::endl;

    Json::Value root1;
    Json::Reader reader1;
    reader1.parse(s1, root1);

    int x1 = root1["x"].asInt();
    int y1 = root1["y"].asInt();
    int z1 = root1["hello world"].asInt();
    std::string k1 = root1["123"].asString();
    printf("x1:%d, y1:%d, z1:%d, k1:%s\n", x1, y1, z1, k1.c_str());

    Json::Value root2;
    Json::Reader reader2;
    reader1.parse(s2, root2);

    int x2 = root2["x"].asInt();
    int y2 = root2["y"].asInt();
    int z2 = root2["hello world"].asInt();
    std::string k2 = root2["123"].asString();
    printf("x2:%d, y2:%d, z2:%d, k2:%s\n", x2, y2, z2, k2.c_str());

    return 0;
}